Computers routinely perform complex tasks by breaking a single, complex task into a series of simpler instructions that the computer understands. These instructions are commonly referred to as “machine instructions,” meaning that they are instructions which a computer processor chip can understand. In fact, even the simplest task for a human may involve a complex set of many different machine instructions. For example, a typical computer-processing chip will need to perform a number of different steps just to count from 2 to 10. A processor may: convert the number 2 into a binary-based value of one's and zero's and store the result in an area of memory known as a register; convert the number to increment by, i.e., the value of 1, to a binary-based value and store the result in another register; convert and store the value of 10 in yet another register; pass the binary values contained in the first two registers to circuits for adding two numbers together; store the sum back in the first register; check the new value in the first register against the value in the second register; and depending on the result of the comparison, repeat the process of adding and storing.
In fact, machine instructions may be broken down into even smaller machine instructions. For example, many chips are based on the CISC architecture (Complex Instruction Set Computer). In CISC, machine instructions can range from relatively simple to rather complex. During operation, each machine instruction is first converted into one or more “microinstructions” and the computer chip then executes the individual microinstructions. The conversion of machine instructions into microinstructions takes up processing time.
Accordingly, in order to increase processing speed, many computer chips now eliminate the conversion step. For example, as its name implies, RISC-based computer systems (Reduced Instruction Set Computer) tend to limit the machine instructions to a set of those instructions that can be immediately executed by the processor in a single time cycle throughput (A RISC processor needs multiple cycles to execute a instruction through a pipeline, but the throughput of the execution is one clock cycle). Thus, the delay in converting the machine instruction is avoided.
However, despite the limited and simplified instructions, many processor chips need to emulate more complex instructions. In some systems, when the chip sees a complex instruction which it cannot execute in a single step, it jumps to an area of the chip which breaks the complex instruction down into individual machine instructions. For example, programs are typically stored as a list of machine instructions, and each machine instruction is stored at its own unique address. The processor generally executes the instructions in sequence unless instructed to jump to a different address. So, when the processor encounters a complex instruction, it may implement a Jump and Link instruction to the area of the chip containing machine instructions that emulate the complex instruction. Specifically, the Jump and Link instruction causes the processor to store the address of the current instruction and then jump to a new address. The processor then executes the machine instruction at the new address. The processor continues executing those instructions until it encounters an instruction to return to the place of the jump. Upon returning, the processor picks up where it left off, i.e., the instruction at the address following the original Jump and Link instruction.
Complex instructions can be emulated using software or hardware. For example, some systems use no special hardware to implement complex instructions; their opcodes are treated as reserved instruction opcodes, which generate exception interrupts. In the interrupt procedure, the complex instruction opcode is examined to check if it is an illegal instruction code or to be emulated as a complex instruction. In other systems, the CPU has hardware to convert a complex instruction to multiple implemented simple instructions, such as microcodes. In these systems, the converting hardware may become quite complex.
There is a need for a system and method which is capable of quickly emulating complex instructions.